<?php

namespace addons\yalimedia;

use app\common\library\Menu;
use think\Addons;

/**
 * 插件
 */
class Yalimedia extends Addons
{

    /**
     * 插件安装方法
     * @return bool
     */
    public function install()
    {
        $menu = [
            [
                'name'    => 'yalimedia',
                'title'   => '课程点播',
                'icon'    => 'fa fa-cubes',
                'sublist' => [
                    [
                        "name"    => "yalimedia/category",
                        "title"   => "分类管理",
                        'ismenu'  => 0,
                        'icon'    => 'fa fa-map-marker',
                        'sublist' => [
                            ["name" => "yalimedia/category/add", "title" => "添加"],
                            ["name" => "yalimedia/category/edit", "title" => "编辑"],
                            ["name" => "yalimedia/category/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/media",
                        "title"   => "素材管理",
                        'icon'    => 'fa fa-list-ul',
                        'sublist' => [
                            ["name" => "yalimedia/media/index", "title" => "查看",],
                            ["name" => "yalimedia/media/add", "title" => "添加"],
                            ["name" => "yalimedia/media/edit", "title" => "编辑"],
                            ["name" => "yalimedia/media/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/ad",
                        "title"   => "轮播图管理",
                        'icon'    => 'fa fa-image',
                        'sublist' => [
                            ["name" => "yalimedia/ad/index", "title" => "查看",],
                            ["name" => "yalimedia/ad/add", "title" => "添加"],
                            ["name" => "yalimedia/ad/edit", "title" => "编辑"],
                            ["name" => "yalimedia/ad/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/menu",
                        "title"   => "图标菜单",
                        'icon'    => 'fa fa-bandcamp',
                        'sublist' => [
                            ["name" => "yalimedia/menu/index", "title" => "查看",],
                            ["name" => "yalimedia/menu/add", "title" => "添加"],
                            ["name" => "yalimedia/menu/edit", "title" => "编辑"],
                            ["name" => "yalimedia/menu/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/shareimg",
                        "title"   => "分享底图",
                        'icon'    => 'fa fa-file-image-o',
                        'sublist' => [
                            ["name" => "yalimedia/shareimg/index", "title" => "查看",],
                            ["name" => "yalimedia/shareimg/add", "title" => "添加"],
                            ["name" => "yalimedia/shareimg/edit", "title" => "编辑"],
                            ["name" => "yalimedia/shareimg/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/coursecategory",
                        "title"   => "课程分类管理",
                        'icon'    => 'fa fa-list-ul',
                        'sublist' => [
                            ["name" => "yalimedia/coursecategory/index", "title" => "查看",],
                            ["name" => "yalimedia/coursecategory/add", "title" => "添加"],
                            ["name" => "yalimedia/coursecategory/edit", "title" => "编辑"],
                            ["name" => "yalimedia/coursecategory/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/course",
                        "title"   => "课程管理",
                        'icon'    => 'fa fa-dedent',
                        'sublist' => [
                            ["name" => "yalimedia/course/index", "title" => "查看",],
                            ["name" => "yalimedia/course/add", "title" => "添加"],
                            ["name" => "yalimedia/course/edit", "title" => "编辑"],
                            ["name" => "yalimedia/course/del", "title" => "删除"],
                            ["name" => "yalimedia/course/content", "title" => "课程内容管理"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/vipcard",
                        "title"   => "会员卡管理",
                        'icon'    => 'fa fa-address-card',
                        'sublist' => [
                            ["name" => "yalimedia/vipcard/index", "title" => "查看",],
                            ["name" => "yalimedia/vipcard/add", "title" => "添加"],
                            ["name" => "yalimedia/vipcard/edit", "title" => "编辑"],
                            ["name" => "yalimedia/vipcard/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/teacher",
                        "title"   => "教师管理",
                        'icon'    => 'fa fa-user',
                        'sublist' => [
                            ["name" => "yalimedia/teacher/index", "title" => "查看",],
                            ["name" => "yalimedia/teacher/add", "title" => "添加"],
                            ["name" => "yalimedia/teacher/edit", "title" => "编辑"],
                            ["name" => "yalimedia/teacher/del", "title" => "删除"],
                        ]
                    ],
                    [
                        "name"    => "yalimedia/order",
                        "title"   => "订单管理",
                        'icon'    => 'fa fa-bar-chart',
                        'sublist' => [
                            ["name" => "yalimedia/order/index", "title" => "查看",],
                            ["name" => "yalimedia/order/add", "title" => "添加"],
                            ["name" => "yalimedia/order/edit", "title" => "编辑"],
                            ["name" => "yalimedia/order/del", "title" => "删除"],
                        ]
                    ],
                ]
            ]
        ];
        Menu::create($menu);
        return true;
    }

    /**
     * 插件卸载方法
     * @return bool
     */
    public function uninstall()
    {
        Menu::delete("yalimedia");
        return true;
    }

    /**
     * 插件启用方法
     * @return bool
     */
    public function enable()
    {

        Menu::enable("yalimedia");
        return true;
    }

    /**
     * 插件禁用方法
     * @return bool
     */
    public function disable()
    {
        Menu::disable("yalimedia");
        return true;
    }

}
